<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
<title>${name_china}管理-新建${name_china}</title>
 <%@include file="/common/headmy.jsp" %>


<!-- 时间日期插件 -->
<link href="<%=request.getContextPath()%>/static/plugin/My97DatePicker/skin/default/datepicker.css" rel="stylesheet" >
<script src="<%=request.getContextPath()%>/static/plugin/My97DatePicker/WdatePicker.js"></script>

<!-- 下拉树插件 -->
<link href="<%=request.getContextPath()%>/static/plugin/zTree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" >
<script src="<%=request.getContextPath()%>/static/plugin/zTree/js/jquery.ztree.all-3.5.min.js"></script>

<!--富文本插件 -->
<%-- <script src="<%=request.getContextPath()%>/static/plugin/ckeditor/ckeditor.js"></script> --%>
<link rel="stylesheet"  href="<%=request.getContextPath()%>/static/editor/themes/default/default.css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/static/editor/kindeditor-min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/editor/lang/zh_CN.js"></script>


</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
            <span class="split"></span>
            <span>新建${name_china}</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="addForm" method="post">
  <div id="left" style="width:80%;float:left">
	 <div class="form-wrapper">
		<div class="h4 distance-double">
	        <span class="h4-title"><i class="icon icon-setting"></i>基本信息</span>
	        <span class="h4-border"></span>
	    </div>
     
         
	     <div class="form-cont">
	        <p class="form-cont-title">账号</p>
	        <input type="text" id="account" name="account" class="summer-input summer-validatebox"  data-validatebox="validType:['required','mobile']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">提现金额</p>
	        <input type="text" id="category" name="category" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[10]']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">提现账号</p>
	        <input type="text" id="drawAccount" name="drawAccount" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[32]']"/> 
	     </div>
	      <div class="form-cont">
	        <p class="form-cont-title">提现类型</p>
	        <input type="text" id="payType" name="payType" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[10]']"/> 
	     </div>
	
	 <div class="form-btn-wrapper" id="funcbar">
        <a class="btn btn-normal" id="backBtn">关闭</a>
    </div>
  </div>
  </div>
	
</form>
<script>
    var  permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
    	KindEditor.ready(function(K) {
    		editor = K.create('textarea[name="styleText",name="styleContent"]', {
    			//uploadJson : '${basePath}/admin/image/imageUpload',
    			uploadJson : basePath + '/fileUpload/imageUpload',
    			allowFileManager : true,
    			allowImageUpload : true,
    			autoHeightMode : true,
    			items : [ 'source','undo', 'redo', '|', 'preview', 'template', 'cut',
    					'copy', 'paste', 'plainpaste', 'wordpaste', '|',
    					'justifyleft', 'justifycenter', 'justifyright',
    					'justifyfull', 'insertorderedlist', 'insertunorderedlist',
    					'indent', 'outdent', 'subscript', 'superscript',
    					'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen',
    					'/', 'formatblock', 'fontname', 'fontsize', '|',
    					'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
    					'strikethrough', 'lineheight', 'removeformat', '|',
    					'image', 'insertfile', 'table', 'hr', 'emoticons',
    					'baidumap', 'pagebreak', 'anchor', 'link', 'unlink' ],
    			afterBlur : function() {
    				this.sync();
    			}
    		});
    	});
    	
    	
    	
    	  //初始化附件
	    initUploadConfig();
	   
    	//初始化funcbar
     	$('#funcbar').prepend($.funcbar({
            type: 'button',
            data: permission,
            permit: ['${name_english}:add']
        }));
   	 	
     	 //下拉初始化
   	    $('#payType').combobox({
   	    	async:false,
   	        defaultValue: editData.payType ,
            valueField : 'code',
            textField : 'name',
            url : COMMON_URL.getCode + '?type=T_WEB_WITHDRAW_PAYTYPE'
        }); 
    	
    	//保存按钮
    	$('#funcbar').on('click', 'a[data-permit="${name_english}:add"]', {isContinue: false},  submit);
    	
    	//返回按钮
    	$('#backBtn,#goBack').on('click',backMain);
    	
    });
    
    
	function initUploadConfig(){
		
		initMyUploadConfig("fileId","imageId","hiddenfile","T_MODEL_TEMPLET","${pageContext.session.id}");
		
	}
	
	  //初始化配置信息
	  function initMyUploadConfig (fileId,imageId,hiddenfile,tableName,sessionId){
         //隐藏图片变量 添加图片回显默认页面
	        $("#"+fileId).attr({"type" : "hidden"});
	        $("#"+imageId).attr({"type" : "hidden"});
            var filestr = `<img id="FileViewId" src=""  width="80px" onerror="javascript:this.src='` + CONST_URL.BASEIMAGE+`'"/>`;
            filestr = filestr + `<input name="file" type="file" accept="image/jpg,image/jpeg,image/png,image/gif" id="file">`;
            $("#"+hiddenfile).append(filestr); 
            initMutiFile(fileId,hiddenfile,tableName,sessionId);
     }

        //初始化图片和视频添加事件(记得动态添加表名)
      function initMutiFile(fileId,hiddenfile,tableName,sessionId){
	
	    //初始化图片上传事件
        var filone=$("#"+hiddenfile); 
        filone.bind('change',function(){  
        });
   }
      //   用 fileIds 获取文件列表 field为列表返名
      function getFileInfos(fileIds,field){
      	 var fileInfo = null;
          $.sajax({
       		type : "get",
       		async : false,
       		url : COMMON_URL.getFileInfos,
       		onLoadSuccess : function(ro){
       			if (ro.result == "success"){
       				fileInfo = ro.data;
       			}
       		},
       		data:{
       			"fileIds" : fileIds,
       			"field" : field,
       		}
       	});
      	 
          return fileInfo;
      }


    
    
    //表单提交
    function submit(event) {
         $("#addForm").form({
        	 buttons : ['#saveBtn','#saveBtnContinue'],
             ajax: {
                 url: CONST_URL.ADD
             },
             onSubmitSuccess: function (data) {
            	 $.stip({
  	                type:'ok',//显示类型 有info、 ok、 danger
  	                text: '保存成功！',
  	                onBeforeHide: function () {
  	            	  var isContinue = event.data.isContinue;
                   	  if (isContinue) {
                          resetForm();
                   	  } else {
                   		  backMain();
                   	  }
  	               }
              	});
              }
         }).form("submit");
    }
    
    //保存并继续清空form
    function resetForm(){
        //$('#xm,#zw,#cs,#bgdh,#sjhm').val('');
    }
    
    //返回主页面
    function backMain() {
    	window.location.href = CONST_URL.INIT_MAIN;
    }
    
   
    //请求url
    var CONST_URL = {
    	INIT_MAIN: basePath + "${common_url}init",
       	ADD: basePath + "${common_url}add",
       	BASEIMAGE: basePath + "/static/images/addimage.png",
    };
    
</script>
</body>
</html>